var photoIndex = 0;

function changePhoto(command)
{
    if (command == 'first')
    {
        photoIndex = 0;
    }

    if (command == 'last')
    {
        photoIndex = fileData.length-1;
    }

    if (command == 'next')
    {
        photoIndex++;

        if (photoIndex > fileData.length-1 )
        {
            photoIndex = fileData.length-1;
        }
    }

    if (command == 'previous')
    {
        photoIndex--;

        if (photoIndex < 0)
        {
            photoIndex = 0;
        }
    }

    var newImage = 'uploaded/'+fileData[photoIndex]+'';
    document.getElementById('imgGaleria').src = newImage;
    if (photoData[fileData[photoIndex]] == undefined)
    {
        photoData[fileData[photoIndex]] = '&nbsp;';
    }
    document.getElementById('msgDiv').innerHTML = photoData[fileData[photoIndex]];
}